/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fertigproz.models;

import fertigproz.*;
import java.sql.SQLException;

/**
 *
 * @author zimmbi
 */
public class PersonModel extends BaseTableModel {

    public static final int COLUMN_ID = 0;
    public static final int COLUMN_NAME = 1;

    public PersonModel(MySQLDriver mysql) {
        super(mysql);
        setQuery("select * from Person");
        String[] columns = new String[]{"ID", "Name"};
        setColumnIdentifiers(columns);
        requery();
    }

    @Override
    public Object getValueAt(int row, int column) {
        if (row >= getRowCount()) {
            return null;
        }
        try {
            results.absolute(row + 1);
            switch (column) {
                case COLUMN_ID:
                    return results.getInt("id");
                case COLUMN_NAME:
                    return results.getString("name");
            }
        } catch (SQLException e) {
        }
        return null;
    }
}
